import * as executor from './executor';
import * as setting from '../app-configure/setting';
import * as handel from '../app-configure/handle';
import ecs from './ecs/ecs'
// @ts-ignore
// 忽略报错

export class App extends cc.EventTarget {
    /**
     * 版本号规则：破坏性.新功能.修复BUG
     */
    appVersion = '5.0.0';

    appReady = false;
    appInited = false;
    cccReady = false;
    cccInited = false;

    static EventType = cc.Enum({
        EVENT_APP_INITED: 'event_app_initer'
    })

    log(str: string, ...args: any[]) { console.log(`[app] [log] ${str}`, ...args); }
    warn(str: string, ...args: any[]) { console.warn(`[app] [warn] ${str}`, ...args); }
    error(str: string, ...args: any[]) { console.error(`[app] [error] ${str}`, ...args); }

    // 数据
    data = executor.data;
    config = executor.config;
    // 设置
    setting = setting;
    // 工具
    tool = executor.tool;
    // 库
    lib = executor.lib;
    // manager
    manager = executor.manager;
    Manager = executor.Manager;
    // ecs
    ecs = ecs;
}
(<any>cc).App = App;

export const app: App = new App();
(<any>cc).app = app;

if (!CC_EDITOR) {
    app.cccReady = true; app.appReady = true;
    handel.cccReady(); handel.appReady();
    cc.game.once(cc.game.EVENT_ENGINE_INITED, function () { app.cccInited = true; handel.cccInited(); });
    app.once(App.EventType.EVENT_APP_INITED, function () { app.appInited = true; handel.appInited(); });
}